/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * Interface.java
 *
 * Created on 30/08/2009, 13:53:33
 */

package main;

import codegen.Organizer;

import codegen.VelocityProcessor;
import utils.EntityUtils;
import xmibase.XmiClass;
import xmibase.XmiPackage;
import java.io.File;

import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
import javax.swing.filechooser.FileFilter;
import utils.FelipeUtils;
import xmiparse.XmiParser;
/**
 *
 * @author Felipe Gutierrez
 */
public class Interface extends javax.swing.JFrame {
    
    
        String outDir = "";
		String templatePathJava = "";
		String xmiFile = "";
        String templatePathIceFaces = "";
        String templatePathPopup = "";
        String templatePathFConfig = "";
        String templatePathCartao = "";
        String outDirIce = "";
        String outDirFConf = "";
        String outDirPopup = "";
         String outDirCartao = "";

        /** Creates new form Interface */
    public Interface() {
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        tFOutDir = new javax.swing.JTextField();
        jButtonOutDir = new javax.swing.JButton();
        tFTemplate = new javax.swing.JTextField();
        tFxmi = new javax.swing.JTextField();
        jButton2 = new javax.swing.JButton();
        jButtonXmiAction = new javax.swing.JButton();
        jButtonGenCode = new javax.swing.JButton();
        jButtonSair = new javax.swing.JButton();
        buttonGenerateIce = new javax.swing.JButton();
        jLabel4 = new javax.swing.JLabel();
        tfTemplateIce = new javax.swing.JTextField();
        buttonIce = new javax.swing.JButton();
        jLabel5 = new javax.swing.JLabel();
        tfOutDirIce = new javax.swing.JTextField();
        buttonOutDirIce = new javax.swing.JButton();
        jLabel6 = new javax.swing.JLabel();
        tfFacesConfig = new javax.swing.JTextField();
        jButtonTemFacesConfig = new javax.swing.JButton();
        jButtonGenFacesConfig = new javax.swing.JButton();
        jLabel7 = new javax.swing.JLabel();
        tfFaces = new javax.swing.JTextField();
        jButton1 = new javax.swing.JButton();
        jLabel8 = new javax.swing.JLabel();
        tfPopup = new javax.swing.JTextField();
        buttonTemPopup = new javax.swing.JButton();
        jButton3 = new javax.swing.JButton();
        jLabel9 = new javax.swing.JLabel();
        tfoutDirPopup = new javax.swing.JTextField();
        btOutDirPopup = new javax.swing.JButton();
        jLabel10 = new javax.swing.JLabel();
        tfCartao = new javax.swing.JTextField();
        btCartao = new javax.swing.JButton();
        btGenCartao = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Interace Utilitária");

        jLabel1.setText("OutDir :");

        jLabel2.setText("Template Path Java :");

        jLabel3.setText("Xmi File :");

        tFOutDir.setEditable(false);

        jButtonOutDir.setText("Choose Out Dir");
        jButtonOutDir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonOutDirActionPerformed(evt);
            }
        });

        tFTemplate.setEditable(false);

        tFxmi.setEditable(false);

        jButton2.setText("Choose Template Dir");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        jButtonXmiAction.setText("Choose XMI File");
        jButtonXmiAction.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonXmiActionActionPerformed(evt);
            }
        });

        jButtonGenCode.setText("Generate Code Java");
        jButtonGenCode.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonGenCodeActionPerformed(evt);
            }
        });

        jButtonSair.setText("Sair");
        jButtonSair.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonSairActionPerformed(evt);
            }
        });

        buttonGenerateIce.setText("Generate Code Icefaces");
        buttonGenerateIce.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonGenerateIceActionPerformed(evt);
            }
        });

        jLabel4.setText("Template Icefaces :");

        tfTemplateIce.setEditable(false);
        tfTemplateIce.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                tfTemplateIceActionPerformed(evt);
            }
        });

        buttonIce.setText("Choose Template Dir");
        buttonIce.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonIceActionPerformed(evt);
            }
        });

        jLabel5.setText("OutDir Icefaces :");

        tfOutDirIce.setEditable(false);

        buttonOutDirIce.setText("Choose Out Dir Ice");
        buttonOutDirIce.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonOutDirIceActionPerformed(evt);
            }
        });

        jLabel6.setText("Template Faces-config.xml :");

        tfFacesConfig.setEditable(false);

        jButtonTemFacesConfig.setText("Choose Template Dir");
        jButtonTemFacesConfig.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonTemFacesConfigActionPerformed(evt);
            }
        });

        jButtonGenFacesConfig.setText("Generate Faces-config.xml");
        jButtonGenFacesConfig.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonGenFacesConfigActionPerformed(evt);
            }
        });

        jLabel7.setText("OutDir Faces Config : ");

        tfFaces.setEditable(false);

        jButton1.setText("Choose Out Dir Faces Config");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        jLabel8.setText("Template Popup : ");

        tfPopup.setEditable(false);

        buttonTemPopup.setText("Choose Template Dir");
        buttonTemPopup.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonTemPopupActionPerformed(evt);
            }
        });

        jButton3.setText("Generate Popup");
        jButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton3ActionPerformed(evt);
            }
        });

        jLabel9.setText("OutDir Popup :");

        tfoutDirPopup.setEditable(false);

        btOutDirPopup.setText("Choose Out Dir Popup");
        btOutDirPopup.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btOutDirPopupActionPerformed(evt);
            }
        });

        jLabel10.setText("Template Cartão :");

        tfCartao.setEditable(false);

        btCartao.setText("Choose Template Dir");
        btCartao.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btCartaoActionPerformed(evt);
            }
        });

        btGenCartao.setText("Generata Cartões");
        btGenCartao.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btGenCartaoActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(78, 78, 78)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel5)
                                    .addComponent(jLabel3)
                                    .addComponent(jLabel1)
                                    .addComponent(jLabel7)
                                    .addComponent(jLabel9))
                                .addGap(33, 33, 33)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(layout.createSequentialGroup()
                                        .addComponent(tfoutDirPopup, javax.swing.GroupLayout.DEFAULT_SIZE, 380, Short.MAX_VALUE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED))
                                    .addGroup(layout.createSequentialGroup()
                                        .addComponent(tFOutDir, javax.swing.GroupLayout.DEFAULT_SIZE, 380, Short.MAX_VALUE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED))
                                    .addGroup(layout.createSequentialGroup()
                                        .addComponent(tFxmi, javax.swing.GroupLayout.DEFAULT_SIZE, 380, Short.MAX_VALUE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED))
                                    .addComponent(tfFaces, javax.swing.GroupLayout.DEFAULT_SIZE, 380, Short.MAX_VALUE)
                                    .addComponent(tfOutDirIce, javax.swing.GroupLayout.DEFAULT_SIZE, 380, Short.MAX_VALUE)))
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel8)
                                    .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 110, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jLabel4))
                                .addGap(28, 28, 28)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(tfTemplateIce, javax.swing.GroupLayout.DEFAULT_SIZE, 381, Short.MAX_VALUE)
                                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                                        .addComponent(tFTemplate, javax.swing.GroupLayout.DEFAULT_SIZE, 381, Short.MAX_VALUE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED))
                                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                                        .addComponent(tfPopup, javax.swing.GroupLayout.DEFAULT_SIZE, 381, Short.MAX_VALUE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED))))
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel6)
                                    .addComponent(jLabel10))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(tfCartao, javax.swing.GroupLayout.DEFAULT_SIZE, 380, Short.MAX_VALUE)
                                    .addComponent(tfFacesConfig, javax.swing.GroupLayout.DEFAULT_SIZE, 380, Short.MAX_VALUE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)))
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addComponent(jButtonTemFacesConfig, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(btOutDirPopup, javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                        .addComponent(jButton1, 0, 0, Short.MAX_VALUE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)))
                                .addGap(7, 7, 7))
                            .addGroup(layout.createSequentialGroup()
                                .addGap(33, 33, 33)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addComponent(buttonOutDirIce)
                                    .addComponent(jButton2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(buttonTemPopup, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(jButtonXmiAction)
                                    .addComponent(buttonIce, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(jButtonOutDir)
                                    .addComponent(btCartao))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 23, Short.MAX_VALUE)))
                        .addGap(39, 39, 39))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jButtonGenCode)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(buttonGenerateIce)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jButtonGenFacesConfig)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jButton3)
                        .addGap(18, 18, 18)
                        .addComponent(btGenCartao)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jButtonSair, javax.swing.GroupLayout.PREFERRED_SIZE, 99, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(61, 61, 61)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel8)
                    .addComponent(tfPopup, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(buttonTemPopup))
                .addGap(21, 21, 21)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel2)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(tFTemplate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jButton2)))
                .addGap(31, 31, 31)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(tfTemplateIce, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(buttonIce))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel10)
                    .addComponent(tfCartao, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btCartao))
                .addGap(15, 15, 15)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel6)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(tfFacesConfig, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jButtonTemFacesConfig)))
                .addGap(40, 40, 40)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel3)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(tFxmi, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jButtonXmiAction)))
                .addGap(43, 43, 43)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(tFOutDir, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButtonOutDir))
                .addGap(40, 40, 40)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel5)
                    .addComponent(tfOutDirIce, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(buttonOutDirIce))
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(35, 35, 35)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(tfFaces, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jButton1))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 9, Short.MAX_VALUE))
                    .addGroup(layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel7)
                        .addGap(18, 18, 18)))
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(16, 16, 16)
                        .addComponent(jLabel9))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(18, 18, 18)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(tfoutDirPopup, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(btOutDirPopup))))
                .addGap(40, 40, 40)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButtonSair)
                    .addComponent(jButtonGenCode)
                    .addComponent(buttonGenerateIce)
                    .addComponent(jButtonGenFacesConfig)
                    .addComponent(jButton3)
                    .addComponent(btGenCartao))
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jButtonOutDirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonOutDirActionPerformed
        // TODO add your handling code here:

           JFileChooser arquivo = new JFileChooser();
           arquivo.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);

           if(arquivo.showOpenDialog(arquivo) == JFileChooser.APPROVE_OPTION){
               File selectedFile = arquivo.getSelectedFile();

               this.tFOutDir.setText(selectedFile.getAbsolutePath());
               this.outDir = selectedFile.getAbsolutePath();

           }

           else{


           }

}//GEN-LAST:event_jButtonOutDirActionPerformed

    private void jButtonXmiActionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonXmiActionActionPerformed
        // TODO add your handling code here:
        JFileChooser fileChooser = new JFileChooser(".");
        FileFilter filter1 = new ExtensionFileFilter("XMI", new String[] { "XMI"});
        fileChooser.setFileFilter(filter1);
        int status = fileChooser.showOpenDialog(null);
        if (status == JFileChooser.APPROVE_OPTION) {
         File selectedFile = fileChooser.getSelectedFile();
         this.tFxmi.setText(selectedFile.getAbsolutePath());
         this.xmiFile = selectedFile.getAbsolutePath();
    } else if (status == JFileChooser.CANCEL_OPTION) {
      System.out.println(JFileChooser.CANCEL_OPTION);
    }


}//GEN-LAST:event_jButtonXmiActionActionPerformed

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        // TODO add your handling code here:

       JFileChooser arquivo = new JFileChooser();
           arquivo.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);

           if(arquivo.showOpenDialog(arquivo) == JFileChooser.APPROVE_OPTION){
               File selectedFile = arquivo.getSelectedFile();

               this.tFTemplate.setText(selectedFile.getAbsolutePath());
               this.templatePathJava = selectedFile.getAbsolutePath();

           }

           else{


           }

    }//GEN-LAST:event_jButton2ActionPerformed

    private void jButtonGenCodeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonGenCodeActionPerformed
        // TODO add your handling code here:

        XmiPackage xmiPKG = new XmiPackage();

        XmiParser parse = new XmiParser(xmiPKG, xmiFile);
        parse.execute();

		Organizer orga = new Organizer();
		orga.execute(xmiPKG);

		VelocityProcessor vl = new VelocityProcessor(templatePathJava, outDir);
                FelipeUtils futils = new FelipeUtils();


		XmiPackage app = orga.getApplicationClasses();
		XmiClass classPessoa = null;


		vl.setApplication(app);

		EntityUtils entityUtils = new EntityUtils();

		//vl.context.put("entityUtils", entityUtils);
		ArrayList<String> listTemplateAvaible = new ArrayList();
		listTemplateAvaible.add("TemplateJava.vm");
        try {

            futils.executeGenClass(listTemplateAvaible, vl , app, outDir);
            //vl.executeGenClass(listTemplateAvaible);
            JOptionPane.showMessageDialog(this,"code generation successfully","code generation successfully",JOptionPane.INFORMATION_MESSAGE);

        } catch (Exception ex) {
            Logger.getLogger(Interface.class.getName()).log(Level.SEVERE, null, ex);
        }
}//GEN-LAST:event_jButtonGenCodeActionPerformed

    private void jButtonSairActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonSairActionPerformed
                    // TODO add your handling code here:

        System.exit(0);
    }//GEN-LAST:event_jButtonSairActionPerformed

    private void buttonGenerateIceActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonGenerateIceActionPerformed
        // TODO add your handling code here:
        XmiPackage xmiPKG = new XmiPackage();

        XmiParser parse = new XmiParser(xmiPKG, xmiFile);
        parse.execute();

		Organizer orga = new Organizer();
		orga.execute(xmiPKG);

		VelocityProcessor vl = new VelocityProcessor(templatePathIceFaces, outDirIce);
                FelipeUtils futils = new FelipeUtils();


		XmiPackage app = orga.getApplicationClasses();
		XmiClass classPessoa = null;


		vl.setApplication(app);

		EntityUtils entityUtils = new EntityUtils();

		//vl.context.put("entityUtils", entityUtils);
		ArrayList<String> listTemplateAvaible = new ArrayList();
		listTemplateAvaible.add("TemplateInterface.vm");
        try {
            futils.executeGenIcefaces(listTemplateAvaible, vl , app, outDirIce);
            //vl.executeGenIcefaces(listTemplateAvaible);
            JOptionPane.showMessageDialog(this,"code generation successfully","code generation successfully",JOptionPane.INFORMATION_MESSAGE);

        } catch (Exception ex) {
            Logger.getLogger(Interface.class.getName()).log(Level.SEVERE, null, ex);
        }







}//GEN-LAST:event_buttonGenerateIceActionPerformed

    private void buttonOutDirIceActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonOutDirIceActionPerformed
        // TODO add your handling code here:
        JFileChooser arquivo = new JFileChooser();
           arquivo.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);

           if(arquivo.showOpenDialog(arquivo) == JFileChooser.APPROVE_OPTION){
               File selectedFile = arquivo.getSelectedFile();

               this.tfOutDirIce.setText(selectedFile.getAbsolutePath());
               this.outDirIce = selectedFile.getAbsolutePath();

           }

           else{


           }


}//GEN-LAST:event_buttonOutDirIceActionPerformed

    private void buttonIceActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonIceActionPerformed
        // TODO add your handling code here:
        JFileChooser arquivo = new JFileChooser();
           arquivo.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);

           if(arquivo.showOpenDialog(arquivo) == JFileChooser.APPROVE_OPTION){
               File selectedFile = arquivo.getSelectedFile();

               this.tfTemplateIce.setText(selectedFile.getAbsolutePath());
               this.templatePathIceFaces = selectedFile.getAbsolutePath();

           }

           else{


           }



    }//GEN-LAST:event_buttonIceActionPerformed

    private void jButtonGenFacesConfigActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonGenFacesConfigActionPerformed
        // TODO add your handling code here:
        XmiPackage xmiPKG = new XmiPackage();

        XmiParser parse = new XmiParser(xmiPKG, xmiFile);
        parse.execute();

		Organizer orga = new Organizer();
		orga.execute(xmiPKG);

		VelocityProcessor vl = new VelocityProcessor(this.templatePathFConfig, outDirFConf);
                FelipeUtils futils = new FelipeUtils();


		XmiPackage app = orga.getApplicationClasses();
		XmiClass classPessoa = null;


		vl.setApplication(app);

		EntityUtils entityUtils = new EntityUtils();

		//vl.context.put("entityUtils", entityUtils);
		ArrayList<String> listTemplateAvaible = new ArrayList();
		listTemplateAvaible.add("TemplateManBean.vm");
        try {
            futils.executeGenFacesConfig(listTemplateAvaible,vl,xmiPKG,outDirFConf);
            //vl.executeGenIcefaces(listTemplateAvaible);
            JOptionPane.showMessageDialog(this,"code generation successfully","code generation successfully",JOptionPane.INFORMATION_MESSAGE);

        } catch (Exception ex) {
            Logger.getLogger(Interface.class.getName()).log(Level.SEVERE, null, ex);
        }

    }//GEN-LAST:event_jButtonGenFacesConfigActionPerformed

    private void jButtonTemFacesConfigActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonTemFacesConfigActionPerformed
        // TODO add your handling code here:
       JFileChooser arquivo = new JFileChooser();
           arquivo.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);

           if(arquivo.showOpenDialog(arquivo) == JFileChooser.APPROVE_OPTION){
               File selectedFile = arquivo.getSelectedFile();

               this.tfFacesConfig.setText(selectedFile.getAbsolutePath());
               this.templatePathFConfig = selectedFile.getAbsolutePath();

           }

           else{


           }

    }//GEN-LAST:event_jButtonTemFacesConfigActionPerformed

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        // TODO add your handling code here:
        JFileChooser arquivo = new JFileChooser();
           arquivo.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);

           if(arquivo.showOpenDialog(arquivo) == JFileChooser.APPROVE_OPTION){
               File selectedFile = arquivo.getSelectedFile();

               this.tfFaces.setText(selectedFile.getAbsolutePath());
               this.outDirFConf = selectedFile.getAbsolutePath();

           }

           else{


           }

    }//GEN-LAST:event_jButton1ActionPerformed

    private void tfTemplateIceActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tfTemplateIceActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_tfTemplateIceActionPerformed

    private void buttonTemPopupActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonTemPopupActionPerformed
        // TODO add your handling code here:
        JFileChooser arquivo = new JFileChooser();
           arquivo.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);

           if(arquivo.showOpenDialog(arquivo) == JFileChooser.APPROVE_OPTION){
               File selectedFile = arquivo.getSelectedFile();

               this.tfPopup.setText(selectedFile.getAbsolutePath());
               this.templatePathPopup = selectedFile.getAbsolutePath();

           }

           else{


           }


    }//GEN-LAST:event_buttonTemPopupActionPerformed

    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
        // TODO add your handling code here:

         XmiPackage xmiPKG = new XmiPackage();

        XmiParser parse = new XmiParser(xmiPKG, xmiFile);
        parse.execute();

		Organizer orga = new Organizer();
		orga.execute(xmiPKG);

		VelocityProcessor vl = new VelocityProcessor(this.templatePathPopup, this.outDirPopup);
                FelipeUtils futils = new FelipeUtils();


		XmiPackage app = orga.getApplicationClasses();
		XmiClass classPessoa = null;


		vl.setApplication(app);

		EntityUtils entityUtils = new EntityUtils();

		//vl.context.put("entityUtils", entityUtils);
		ArrayList<String> listTemplateAvaible = new ArrayList();
		listTemplateAvaible.add("popup2.vm");
                
        try {
            futils.executeGenIPopup(listTemplateAvaible, vl , app, this.outDirPopup);
            
            //vl.executeGenIcefaces(listTemplateAvaible);
            JOptionPane.showMessageDialog(this,"code generation successfully","code generation successfully",JOptionPane.INFORMATION_MESSAGE);

        } catch (Exception ex) {
            Logger.getLogger(Interface.class.getName()).log(Level.SEVERE, null, ex);
        }

    }//GEN-LAST:event_jButton3ActionPerformed

    private void btOutDirPopupActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btOutDirPopupActionPerformed
        // TODO add your handling code here:

        JFileChooser arquivo = new JFileChooser();
           arquivo.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);

           if(arquivo.showOpenDialog(arquivo) == JFileChooser.APPROVE_OPTION){
               File selectedFile = arquivo.getSelectedFile();

               this.tfoutDirPopup.setText(selectedFile.getAbsolutePath());
               this.outDirPopup = selectedFile.getAbsolutePath();

           }

           else{


           }

    }//GEN-LAST:event_btOutDirPopupActionPerformed

    private void btCartaoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btCartaoActionPerformed
        // TODO add your handling code here:
        JFileChooser arquivo = new JFileChooser();
           arquivo.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);

           if(arquivo.showOpenDialog(arquivo) == JFileChooser.APPROVE_OPTION){
               File selectedFile = arquivo.getSelectedFile();

               this.tfCartao.setText(selectedFile.getAbsolutePath());
               this.templatePathCartao = selectedFile.getAbsolutePath();

           }

           else{


           }

    }//GEN-LAST:event_btCartaoActionPerformed

    private void btGenCartaoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btGenCartaoActionPerformed
        // TODO add your handling code here:
        XmiPackage xmiPKG = new XmiPackage();

        XmiParser parse = new XmiParser(xmiPKG, xmiFile);
        parse.execute();

		Organizer orga = new Organizer();
		orga.execute(xmiPKG);

		VelocityProcessor vl = new VelocityProcessor(this.templatePathCartao, this.outDirPopup);
                FelipeUtils futils = new FelipeUtils();


		XmiPackage app = orga.getApplicationClasses();
		XmiClass classPessoa = null;


		vl.setApplication(app);

		EntityUtils entityUtils = new EntityUtils();

		//vl.context.put("entityUtils", entityUtils);
		ArrayList<String> listTemplateAvaible = new ArrayList();
		listTemplateAvaible.add("TemplateHtml.vm");
        try {
            futils.executeGenHtml(listTemplateAvaible,vl,xmiPKG,this.outDirPopup);
            //vl.executeGenIcefaces(listTemplateAvaible);
            JOptionPane.showMessageDialog(this,"code generation successfully","code generation successfully",JOptionPane.INFORMATION_MESSAGE);

        } catch (Exception ex) {
            Logger.getLogger(Interface.class.getName()).log(Level.SEVERE, null, ex);
        }



    }//GEN-LAST:event_btGenCartaoActionPerformed

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new Interface().setVisible(true);
            }
        });
    }

  class ExtensionFileFilter extends FileFilter {
  String description;

  String extensions[];

  public ExtensionFileFilter(String description, String extension) {
    this(description, new String[] { extension });
  }

  public ExtensionFileFilter(String description, String extensions[]) {
    if (description == null) {
      this.description = extensions[0];
    } else {
      this.description = description;
    }
    this.extensions = (String[]) extensions.clone();
    toLower(this.extensions);
  }

  private void toLower(String array[]) {
    for (int i = 0, n = array.length; i < n; i++) {
      array[i] = array[i].toLowerCase();
    }
  }

  public String getDescription() {
    return description;
  }

  public boolean accept(File file) {
    if (file.isDirectory()) {
      return true;
    } else {
      String path = file.getAbsolutePath().toLowerCase();
      for (int i = 0, n = extensions.length; i < n; i++) {
        String extension = extensions[i];
        if ((path.endsWith(extension) && (path.charAt(path.length() - extension.length() - 1)) == '.')) {
          return true;
        }
      }
    }
    return false;
  }
}


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btCartao;
    private javax.swing.JButton btGenCartao;
    private javax.swing.JButton btOutDirPopup;
    private javax.swing.JButton buttonGenerateIce;
    private javax.swing.JButton buttonIce;
    private javax.swing.JButton buttonOutDirIce;
    private javax.swing.JButton buttonTemPopup;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButtonGenCode;
    private javax.swing.JButton jButtonGenFacesConfig;
    private javax.swing.JButton jButtonOutDir;
    private javax.swing.JButton jButtonSair;
    private javax.swing.JButton jButtonTemFacesConfig;
    private javax.swing.JButton jButtonXmiAction;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JTextField tFOutDir;
    private javax.swing.JTextField tFTemplate;
    private javax.swing.JTextField tFxmi;
    private javax.swing.JTextField tfCartao;
    private javax.swing.JTextField tfFaces;
    private javax.swing.JTextField tfFacesConfig;
    private javax.swing.JTextField tfOutDirIce;
    private javax.swing.JTextField tfPopup;
    private javax.swing.JTextField tfTemplateIce;
    private javax.swing.JTextField tfoutDirPopup;
    // End of variables declaration//GEN-END:variables

}
